// -----------------------------------------------
// Author:     code34 nicolas_boiteux@yahoo.fr
// Edited by:  Neumatic
// Warcontext: Create a marker
// -----------------------------------------------

private [
	"_indexparameters",
	"_markertype",
	"_markerdir",
	"_markertext",
	"_protect",
	"_parameters",
	"_nbparameters",
	"_tmparray",
	"_markername",
	"_markersize",
	"_markerposition",
	"_markercolor",
	"_markershape",
	"_markerbrush",
	"_marker"
];

_parameters = [
	"_markername",
	"_markersize",
	"_markerposition",
	"_markercolor",
	"_markershape",
	"_markerbrush",
	"_markertype",
	"_markerdir",
	"_markertext",
	"_protect"
];

_indexparameters = 0;
_nbparameters = count _this;
{
	if (_indexparameters <= _nbparameters) then {
		call compile format ["%1 = _this select %2;", _x, _indexparameters];
	};
	_indexparameters = _indexparameters + 1;
} foreach _parameters;

if (isNil "_markertype") then { _markertype = "" };
if (isNil "_markerdir") then {  _markerdir = 0 };
if (isNil "_markertext") then { _markertext = "" };
if (isNil "_protect") then {    _protect = false };

_tmparray = [_markername, _markersize, _markerposition, _markercolor, _markershape, _markerbrush, _markertype, _markerdir, _markertext, _protect];
wcarraymarker = wcarraymarker + [_tmparray];
_marker = createMarker [_markername, _markerposition];
if (!isNil "_markersize") then { _marker setMarkerSize [_markersize, _markersize] };
if (_markershape != "") then {   _marker setMarkershape _markershape };
if (_markercolor != "") then {   _marker setMarkerColor _markercolor };
if (_markerbrush != "") then {   _marker setMarkerBrush _markerbrush };
if (_markertext != "") then {    _marker setMarkerText _markertext };
if (!isNil "_markerdir") then {  _marker setMarkerDir _markerdir };
if (!isNil "_markertype") then { _marker setMarkerType _markertype };

_marker;